﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace _09_DellAllOddLines
{
    class DellOddLine
    {
        static void Main(string[] args)
        {
            StreamReader inputReader = new StreamReader("text.txt");
            StringBuilder result = new StringBuilder();            
            using (inputReader)
            {
                int lineNum = 0;
                result.Append("Result: \r\n");
                while (inputReader.EndOfStream != true)
                {
                    string line = inputReader.ReadLine();
                    lineNum++;
                    if (lineNum % 2 == 0)
                    {
                        result.Append(line);
                        result.Append("\r\n");
                    }
                }
            }
            StreamWriter outputWreiter = new StreamWriter("text.txt", true);//true - to append to existing file; false - to replace the content.
            using (outputWreiter)
            {
                outputWreiter.WriteLine();
                outputWreiter.WriteLine(result.ToString());
            }
        }
    }
}
